<!-- 详情 -->
<template>
  <div class="drawer-layout">
    <el-drawer
      :title="detailTitle"
      :visible.sync="drawer"
      @closed="closedinvitation"
      size="60%"
      :wrapperClosable="false"
    >
      <div class="layout" style="position: relative" v-loading="loading">
        <!-- <div
          class="info-box"
          style="display: flex; justify-content: space-between"
        >
          <div>
            <div style="display: flex; margin-bottom: 20px">
              <el-image
                src="https://mj-1320609740.cos.ap-nanjing.myqcloud.com/2023-11/29/090032_27092.jpeg"
                style="height: 50px; width: 50px; border-radius: 5px"
              ></el-image>
              <div
                style="margin-left: 20px; line-height: 26px; font-size: 14px"
              >
                <div style="display: flex">
                  <div>{{ dataObj.mer_name }}</div>
                  <div style="margin-left: 20px">
                    <span style="color: #626262">联系方式：</span
                    >{{ dataObj.mer_user_cellphone }}
                  </div>
                </div>
                <div style="display: flex">
                  <div class="idbox">单号:1234566</div>
                  <div style="margin-left: 20px;">联系方式：18100000000</div>
                </div>
              </div>
            </div>
          </div>
          <div>
            审核状态：

        </div> -->
        <div class="blockquote-box">充值信息</div>
        <div class="info-box">
          <el-descriptions :column="2">
            <el-descriptions-item label="商户名称">{{
              dataObj.mer_name
            }}</el-descriptions-item>
            <el-descriptions-item label="审核状态">
              <span
                v-if="dataObj.apply_status == 1"
                style="color: #e6a23c; font-weight: 600"
                >待审核</span
              >
              <span
                v-if="dataObj.apply_status == 2"
                style="color: #67c23a; font-weight: 600"
                >审核通过</span
              >
              <span
                v-if="dataObj.apply_status == 3"
                style="color: #f56c6c; font-weight: 600"
                >审核失败</span
              >
            </el-descriptions-item>
            <el-descriptions-item label="姓名">
              {{ dataObj.mer_user_name }}
            </el-descriptions-item>
            <el-descriptions-item label="联系方式">
              {{ dataObj.mer_user_cellphone }}
            </el-descriptions-item>

            <el-descriptions-item label="收款方式">
              {{ dataObj.type_text }}
            </el-descriptions-item>
            <el-descriptions-item label="提现状态">{{
              dataObj.status_text
            }}</el-descriptions-item>
            <el-descriptions-item label="提现金额">{{
              dataObj.price
            }}</el-descriptions-item>
            <el-descriptions-item label="到账金额">{{
              dataObj.payment
            }}</el-descriptions-item>
            <el-descriptions-item label="费率">{{
              dataObj.rate
            }}</el-descriptions-item>
            <el-descriptions-item label="手续费">{{
              dataObj.rate_fee
            }}</el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="blockquote-box">账户信息</div>
        <div class="info-box">
          <el-descriptions :column="2">
            <el-descriptions-item label="账户类型">{{
              dataObj.payment_info.bank_name
            }}</el-descriptions-item>
            <el-descriptions-item label="账户号">{{
              dataObj.payment_info.bank_card_number
            }}</el-descriptions-item>
            <el-descriptions-item label="姓名">{{
              dataObj.payment_info.bank_user_name
            }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{
              dataObj.payment_info.reserve_cellphone
            }}</el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="blockquote-box">审核信息</div>
        <el-form
          v-loading="loading"
          class="search-form"
          label-position="right"
          label-width="80px"
          size="small"
          ref="searchForm"
          :model="searchForm"
          :rules="searchRule"
        >
          <el-form-item
            label="审核状态"
            class="search-form-item"
            prop="apply_status"
          >
            <el-radio-group
              v-if="dataObj.apply_status == 1"
              v-model="searchForm.apply_status"
            >
              <el-radio
                v-for="(item, index) in [
                  { id: 3, name: '驳回' },
                  { id: 2, name: '通过' },
                ]"
                :key="index"
                :label="item.id"
                >{{ item.name }}</el-radio
              >
            </el-radio-group>
            <div v-else>
              <el-tag v-if="dataObj.apply_status == 2" type="success"
                >已通过</el-tag
              >
              <el-tag v-else type="danger">已驳回</el-tag>
            </div>
          </el-form-item>
          <el-form-item label="审核备注" class="search-form-item" prop="remark">
            <el-input
              v-if="dataObj.apply_status == 1"
              type="textarea"
              :rows="5"
              placeholder="请输入内容"
              v-model="searchForm.remark"
            ></el-input>
            <span v-else>
              {{ dataObj.remark ? dataObj.remark : "-" }}
            </span>
          </el-form-item>
        </el-form>
        <div
          style="display: flex; justify-content: center; margin: 20px"
          v-if="dataObj.apply_status == 1"
        >
          <el-button :loading="loading" type="primary" @click="save()"
            >保存</el-button
          >
        </div>
      </div>
    </el-drawer>
  </div>
</template>
<script>
// 引入
import LogoUpload from "@/components/FileUpload";
import { list, audits } from "@/api/finance/index";
export default {
  name: "detail",
  props: ["detailTitle", "dataObj"],
  components: {
    LogoUpload,
  },
  data() {
    return {
      loading: false,
      id: "",
      drawer: true,
      detailtitle: "",
      activeName: "first",
      searchForm: {
        apply_status: 2,
        remark: "",
      },
      searchRule: {
        apply_status: [
          { required: true, message: "审核状态必填", trigger: "blur" },
        ],
        remark: [
          {
            required: false,
            validator: (rule, value, callback) => {
              if (this.searchForm.apply_status == 2) {
                if (value == "" || !value) {
                  callback(new Error("请输入驳回原因"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    save() {
      this.$refs.searchForm.validate((valid) => {
        if (valid) {
          this.$confirm("请仔细核对当前信息，仔细核对哦！", "确认操作", {
            confirmButtonText: "我已核对",
            cancelButtonText: "我再看看",
            type: "success",
          })
            .then(async () => {
              this.loading = true;
              this.searchForm.id = this.dataObj.id;
              const res = await audits(this.searchForm);
              const { code, msg } = res;
              if (code === 200) {
                // 更新数据
                this.loading = false;
                this.dataObj.apply_status = this.searchForm.apply_status;
                this.dataObj.remark = this.searchForm.remark;
                this.$messages.success(res.msg);
              } else {
                this.loading = false;
                this.$message.error(msg);
              }
            })
            .catch(() => {});
        } else {
        }
      });
    },
    // 关闭添加抽屉
    closedinvitation() {
      this.$parent.closedetail();
    },
  },
};
</script>
<style lang="scss">
.drawer-layout {
  /*1.显示滚动条：当内容超出容器的时候，可以拖动：*/
  .el-drawer__body {
    overflow: auto;
  }

  /*2.隐藏滚动条，太丑了*/
  .el-drawer__container ::-webkit-scrollbar {
    display: none;
  }

  .el-drawer__header {
    background-color: #409eff;
    color: #ffffff;
    padding: 10px 20px;
    margin-bottom: 10px;
  }

  .el-tabs--card {
    height: calc(100vh - 110px);
    /* overflow-y: auto; */
  }

  .el-tab-pane {
    height: calc(100vh - 110px);
    overflow-y: auto;
  }

  .el-tabs__header {
    padding-left: 50px;
    margin: 0;
  }

  .el-tabs__item {
    padding: 0 40px;
  }

  .el-tabs__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #ffffff;
    z-index: 1;
  }

  .el-alert--warning.is-light .el-alert__description {
    color: #c77b04;
    font-size: 14px;
  }

  .form-box-item {
    .el-form-item__label {
      font-size: 14px;
      font-weight: 500;
      // width: 96px;
    }

    .el-input {
      width: 250px;
    }
  }
}
</style>
<style lang="scss" scoped>
.blockquote-box {
  border-left: 4px solid #409eff;
  padding-left: 16px;
  margin: 16px 0;
  height: 40px;
  line-height: 40px;
  background: #fafafa;
  font-size: 16px;
}

.info-box {
  margin: 0 20px 20px 20px;
}

.infodiv {
  color: #626262;
  font-size: 14px;
  width: 50%;

  div {
    margin-bottom: 20px;
  }
}

.idbox {
  border: 1px solid #cecece;
  border-radius: 3px;
  font-size: 12px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  color: #838281;
}
</style>